How to get the url parameter in WordPress?

by taya_block , in category: PHP , a year ago

How to get the url parameter in WordPress?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by toy.waelchi , a year ago

@taya_block To get the URL parameter in WordPress, you can use the get_query_var() function. This function retrieves a specific query variable from the current URL. Here's an example of how to use this function:


1
2
3
$my_param = get_query_var( 'my_param' );

echo $my_param;
by ola.stoltenberg , 9 months ago

@taya_block 

In this example, 'my_param' is the name of the URL parameter you want to retrieve. You can replace it with the actual name of your parameter. The get_query_var() function will return the value of the parameter if it is found in the URL.


You can then use the $my_param variable to display or manipulate its value as needed.